
set(ProjectName swr)
set( SRC_LIST
	color_buffer.h
	color_buffer.cpp
)

include_directories(w32)
add_library(${ProjectName} SHARED ${SRC_LIST})
target_link_libraries(${ProjectName} w32)

set_target_properties(${ProjectName} PROPERTIES FOLDER BaseLib)
install(TARGETS ${ProjectName} RUNTIME DESTINATION ${INSTALL_DIR} )
install(TARGETS ${ProjectName} ARCHIVE DESTINATION ${LIBRARY_DIR} )
#install(FILES color_buffer.h DESTINATION ${INCLUDE_DIR} )

# lua export dll

set(LUA_EXPORT_CPP ${CMAKE_CURRENT_BINARY_DIR}/lua_${ProjectName}.cpp)
set(LUA_EXPORT_PKG ${ProjectName}.pkg)
set(LUA_EXPORT_DLL lua_${ProjectName})

add_custom_command(OUTPUT ${LUA_EXPORT_CPP}
                     COMMAND ${TOLUABIN} -o ${LUA_EXPORT_CPP} ${LUA_EXPORT_PKG}
                     MAIN_DEPENDENCY ${LUA_EXPORT_PKG}
                     DEPENDS ${SRC_LIST}
                     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                     COMMENT "generate ${LUA_EXPORT_CPP}...")

add_library(${LUA_EXPORT_DLL} SHARED ${LUA_EXPORT_CPP})

target_link_libraries(${LUA_EXPORT_DLL}
	lua51
	tolua++
	${ProjectName}
)

set_target_properties(${LUA_EXPORT_DLL} PROPERTIES FOLDER lualibs)
install(TARGETS ${LUA_EXPORT_DLL} RUNTIME DESTINATION ${INSTALL_DIR})
